<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
    <title>ShellCheck: SC1082 – This file has a UTF-8 BOM. Remove it with: `LC_CTYPE=C sed '1s/^...//' < yourscript`.</title>
    <link rel="stylesheet" href="css/bootstrap.min.css" />
  </head>
  <body style="margin-left: auto; margin-right: auto; max-width: 800px">
    <h1>SC1082 – ShellCheck Wiki</h1>
    <a href="https://github.com/koalaman/shellcheck/wiki/SC1082">See this page on GitHub</a>
    <p style="display: none"><a href="index.html">Sitemap</a></p>
    <hr />
    <h2
id="this-file-has-a-utf-8-bom-remove-it-with-lc_ctypec-sed-1s--yourscript">This
file has a UTF-8 BOM. Remove it with:
<code>LC_CTYPE=C sed '1s/^...//' &lt; yourscript</code>.</h2>
<h3 id="problematic-code">Problematic code:</h3>
<p>This is an encoding error that can't be seen in the script itself,
but <code>cat -v</code> will show three bytes of garbage at the start of
the file:</p>
<pre><code>$ cat -v file
M-oM-;M-?#!/bin/bash
echo &quot;hello world&quot;</code></pre>
<h3 id="correct-code">Correct code:</h3>
<p>The code is correct when this garbage does not appear.</p>
<h3 id="rationale">Rationale:</h3>
<p>Some editors may save a file with a <a
href="https://en.wikipedia.org/wiki/Byte_order_mark">Byte Order Mark</a>
to mark the file as UTF-8. Shells do not understand this and will give
errors on the first line:</p>
<pre><code>$ bash myscript
myscript: line 1: #!/bin/sh: No such file or directory

$ dash myscript
myscript: 1: myscript: #!/bin/sh: not found</code></pre>
<p>To fix it, remove the byte order mark. One way of doing this is
<code>LC_CTYPE=C sed '1s/^...//' &lt; yourscript</code>. Verify that
it's not there with <code>cat -v</code>.</p>
<h3 id="exceptions">Exceptions:</h3>
<p>None</p>
    <hr />
    <p style='font-size: 80%'><a href="../index.html">ShellCheck</a> is a static analysis tool for shell scripts. This page is part of its documentation.</p>
  </body>
</html>


